package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbContentCategoryMapper;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.service.CategoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class CategoryServiceImpl implements CategoryService {

    @Resource
    private TbContentCategoryMapper tm;

    @Override
    public List<TbContentCategory> getAll(String name) {
        return tm.selectByName(name);
    }

    @Override
    public int delete(Long id) {
        return tm.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TbContentCategory cate) {
        return tm.insertSelective(cate);
    }

    @Override
    public TbContentCategory getById(Long id) {
        return tm.selectByPrimaryKey(id);
    }

    @Override
    public int update(TbContentCategory cate) {
        return tm.updateByPrimaryKeySelective(cate);
    }

    @Override
    public int deleteCheck(Long[] ids) {
        for (Long id : ids) {
            delete(id);
        }
        return 1;
    }
}
